-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ansible playbook to clean nodes in inventory #104
base: main
Are you sure you want to change the base?
Conversation
4edc49c
to
88b4e6c
Compare
@@ -0,0 +1,36 @@ | |||
- name: Playbook to clean jenkins agents by removing workspaces. | |||
hosts: all | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be useful if there is an additional section to log the directories that would be deleted via this. For example, having some logging tasks that will always
run regardless of the tag
specified would list the existing directories along with their sizes.
The same can be used to check the existing dirs before deleting as well(By first running without giving any tags).
- name: Collect existing dir names and their sizes | |
community.docker.docker_container_exec: | |
container: "{{ agent_name }}" | |
command: bash -l -c "du -sh * | awk '{print $1, $2}'" | |
chdir: "/jenkins_workdir/workspace" | |
register: dirs_and_sizes | |
become: yes | |
tags: [always] | |
- name: Log existing dirs with their sizes | |
debug: | |
msg: "{{ dirs_and_sizes.stdout_lines }}" | |
tags: [always] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting a small change to log the directories before cleaning. Otherwise the changes look good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, tested this on isis-cloud-linux-b-5
node(made the node temporarily offline) with nightly
tag and it worked as expected.
Node is back online now and I am happy to approve!
Cleans the jenkins workspace stored in docker containers for a set of nodes defined in the
inventory.txt
file.Provides tags to determine which of the pipeline's workspaces should be cleaned. Otherwise, does them all.
To Test:
Fixes #103